import React, { useState } from 'react';
import { FlatList, Text, View, Button } from 'react-native';

interface CellItem {
  id: number,
  text: string,
}

const App = () => {
  const [items, setItems] = useState([
    { id: 1, text: 'Item 1' },
    { id: 2, text: 'Item 2' },
    { id: 3, text: 'Item 3' },
    // ... 更多items
  ]);
 
  const updateItem = (itemId, newText) => {
    setItems(prevItems =>
      prevItems.map(item => {
        if (item.id === itemId) {
          return { ...item, text: newText };
        }
        return item;
      })
    );
  };
 
  const renderItem = ({ item }) => (
    <View>
      <Text>{item.text}</Text>
      <Button
        onPress={() => updateItem(item.id, `${item.text} (updated)`)}
        title="Update"
      />
    </View>
  );
 
  return (
    <FlatList
      data={items}
      renderItem={renderItem}
      keyExtractor={item => item.id.toString()}
    />
  );
};
 
export default App;